
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@aws-cdk/aws-lambda
Advanced tools
This construct library allows you to define AWS Lambda Functions.
import lambda = require('@aws-cdk/aws-lambda');
const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NodeJS810,
handler: 'index.handler',
code: lambda.Code.inline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
});
The lambda.Code
class includes static convenience methods for various types of
runtime code.
lambda.Code.bucket(bucket, key[, objectVersion])
- specify an S3 object that
contains the archive of your runtime code.lambda.Code.inline(code)
- inline the handle code as a string. This is
limited to 4KB. The class InlineJavaScriptLambda
can be used to simplify
inlining JavaScript functions.lambda.Code.directory(directory)
- specify a directory in the local filesystem
which will be zipped and uploaded to S3 before deployment.lambda.Code.file(path)
- specify a file to be used for Lambda code. This can
be, for example a JAR or a ZIP file, based on the runtime used.The following example shows how to define a Python function and deploy the code from the
local directory my-lambda-handler
to it:
Example of Lambda Code from Local Assets
When deploying a stack that contains this code, the directory will be zip archived and then uploaded to an S3 bucket, then the exact location of the S3 objects will be passed when the stack is deployed.
This module also contains an Action that allows you to invoke a Lambda function from CodePipeline:
import codepipeline = require('@aws-cdk/aws-codepipeline');
import lambda = require('@aws-cdk/aws-lambda');
const lambdaFun = new lambda.Function(this, 'MyLambda', {
// some lambda parameters here...
});
const pipeline = new codepipeline.Pipeline(this, 'MyPipeline');
const lambdaStage = new codepipeline.Stage(this, 'Lambda', {
pipeline,
});
new lambda.PipelineInvokeAction(this, 'Lambda', {
stage: lambdaStage,
lambda: lambdaFun,
});
See the AWS documentation on how to write a Lambda function invoked from CodePipeline.
import lambda = require('@aws-cdk/aws-lambda');
const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NodeJS810,
handler: 'index.handler',
code: lambda.Code.inline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
deadLetterQueueEnabled: true
});
See the AWS documentation to learn more about AWS Lambdas and DLQs.
import lambda = require('@aws-cdk/aws-lambda');
const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NodeJS810,
handler: 'index.handler',
code: lambda.Code.inline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
tracing: lambda.Tracing.Active
});
See the AWS documentation to learn more about AWS Lambda's X-Ray support.
0.10.0 (2018-09-27)
This release introduces a better way to "escape" L2 constructs in case of missing features by adding the ability to add arbitrary overrides for resource properties:
const bucket = new s3.Bucket(this, 'L2Bucket');
// access L1
const bucketResource = bucket.findChild('Resource') as s3.cloudformation.BucketResource;
// strongly-typed overrides
bucketResource.propertyOverrides.bucketName = 'amzn-s3-demo-bucket';
// weakly-typed overrides
bucketResource.addPropertyOverride('BucketName', 'amzn-s3-demo-bucket1');
TagManager
has changed. initialTags
is now passed inside a props object.@aws-cdk/util
is no longer available@aws-cdk/cfnspec: Updated [CloudFormation resource specification] to v2.8.0
([@RomainMuller] in #767)
New Construct Libraries
@aws-cdk/aws-amazonmq
@aws-cdk/aws-iot1click
New Resource Types
Attribute Changes
Property Changes
AWS::ApiGateway::Deployment DeploymentCanarySettings (added)
AWS::ApiGateway::Method AuthorizationScopes (added)
AWS::ApiGateway::Stage AccessLogSetting (added)
AWS::ApiGateway::Stage CanarySetting (added)
AWS::AutoScaling::AutoScalingGroup LaunchTemplate (added)
AWS::CodeBuild::Project LogsConfig (added)
AWS::CodeBuild::Project SecondaryArtifacts (added)
AWS::CodeBuild::Project SecondarySources (added)
AWS::CodeDeploy::DeploymentGroup Ec2TagSet (added)
AWS::CodeDeploy::DeploymentGroup OnPremisesTagSet (added)
AWS::EC2::FlowLog LogDestination (added)
AWS::EC2::FlowLog LogDestinationType (added)
AWS::EC2::FlowLog DeliverLogsPermissionArn.Required (changed)
AWS::EC2::FlowLog LogGroupName.Required (changed)
AWS::EC2::VPCEndpoint IsPrivateDnsEnabled (deleted)
AWS::EC2::VPCEndpoint PrivateDnsEnabled (added)
AWS::EC2::VPCEndpoint RouteTableIds.DuplicatesAllowed (added)
AWS::EC2::VPCEndpoint SecurityGroupIds.DuplicatesAllowed (added)
AWS::EC2::VPCEndpoint SubnetIds.DuplicatesAllowed (added)
AWS::EC2::VPCEndpoint VPCEndpointType.UpdateType (changed)
AWS::ECS::Service SchedulingStrategy (added)
AWS::ECS::Service ServiceRegistries.UpdateType (changed)
AWS::ElastiCache::ReplicationGroup NodeGroupConfiguration.UpdateType (changed)
AWS::ElastiCache::ReplicationGroup NumNodeGroups.UpdateType (changed)
AWS::RDS::DBCluster EngineMode (added)
AWS::RDS::DBCluster ScalingConfiguration (added)
AWS::SageMaker::NotebookInstance LifecycleConfigName.UpdateType (changed)
Property Type Changes
AWS::ApiGateway::Deployment.AccessLogSetting (added)
AWS::ApiGateway::Deployment.CanarySetting (added)
AWS::ApiGateway::Deployment.DeploymentCanarySettings (added)
AWS::ApiGateway::Stage.AccessLogSetting (added)
AWS::ApiGateway::Stage.CanarySetting (added)
AWS::AutoScaling::AutoScalingGroup.LaunchTemplateSpecification (added)
AWS::CodeBuild::Project.CloudWatchLogsConfig (added)
AWS::CodeBuild::Project.LogsConfig (added)
AWS::CodeBuild::Project.S3LogsConfig (added)
AWS::CodeDeploy::DeploymentGroup.EC2TagSet (added)
AWS::CodeDeploy::DeploymentGroup.EC2TagSetListObject (added)
AWS::CodeDeploy::DeploymentGroup.OnPremisesTagSet (added)
AWS::CodeDeploy::DeploymentGroup.OnPremisesTagSetListObject (added)
AWS::EC2::SpotFleet.ClassicLoadBalancer (added)
AWS::EC2::SpotFleet.ClassicLoadBalancersConfig (added)
AWS::EC2::SpotFleet.FleetLaunchTemplateSpecification (added)
AWS::EC2::SpotFleet.LaunchTemplateConfig (added)
AWS::EC2::SpotFleet.LaunchTemplateOverrides (added)
AWS::EC2::SpotFleet.LoadBalancersConfig (added)
AWS::EC2::SpotFleet.TargetGroup (added)
AWS::EC2::SpotFleet.TargetGroupsConfig (added)
AWS::ECS::TaskDefinition.DockerVolumeConfiguration (added)
AWS::ECS::TaskDefinition.RepositoryCredentials (added)
AWS::ECS::TaskDefinition.Tmpfs (added)
AWS::Events::Rule.SqsParameters (added)
AWS::RDS::DBCluster.ScalingConfiguration (added)
AWS::ApiGateway::Deployment.StageDescription AccessLogSetting (added)
AWS::ApiGateway::Deployment.StageDescription CanarySetting (added)
AWS::ApiGateway::Method.Integration ConnectionId (added)
AWS::ApiGateway::Method.Integration ConnectionType (added)
AWS::ApiGateway::Method.Integration TimeoutInMillis (added)
AWS::ApiGateway::UsagePlan.ApiStage Throttle (added)
AWS::CodeBuild::Project.Artifacts ArtifactIdentifier (added)
AWS::CodeBuild::Project.Source SourceIdentifier (added)
AWS::CodeBuild::Project.VpcConfig SecurityGroupIds.Required (changed)
AWS::CodeBuild::Project.VpcConfig Subnets.Required (changed)
AWS::CodeBuild::Project.VpcConfig VpcId.Required (changed)
AWS::CodeDeploy::DeploymentGroup.EC2TagFilter Key.Documentation (changed)
AWS::CodeDeploy::DeploymentGroup.EC2TagFilter Type.Documentation (changed)
AWS::CodeDeploy::DeploymentGroup.EC2TagFilter Value.Documentation (changed)
AWS::CodeDeploy::DeploymentGroup.TagFilter Key.Documentation (changed)
AWS::CodeDeploy::DeploymentGroup.TagFilter Type.Documentation (changed)
AWS::CodeDeploy::DeploymentGroup.TagFilter Value.Documentation (changed)
AWS::EC2::SpotFleet.SpotFleetRequestConfigData InstanceInterruptionBehavior (added)
AWS::EC2::SpotFleet.SpotFleetRequestConfigData LaunchTemplateConfigs (added)
AWS::EC2::SpotFleet.SpotFleetRequestConfigData LoadBalancersConfig (added)
AWS::EC2::SpotFleet.SpotPlacement Tenancy (added)
AWS::ECS::Service.ServiceRegistry ContainerName (added)
AWS::ECS::Service.ServiceRegistry ContainerPort (added)
AWS::ECS::Service.ServiceRegistry Port.UpdateType (changed)
AWS::ECS::Service.ServiceRegistry RegistryArn.UpdateType (changed)
AWS::ECS::TaskDefinition.ContainerDefinition RepositoryCredentials (added)
AWS::ECS::TaskDefinition.LinuxParameters SharedMemorySize (added)
AWS::ECS::TaskDefinition.LinuxParameters Tmpfs (added)
AWS::ECS::TaskDefinition.Volume DockerVolumeConfiguration (added)
AWS::ElastiCache::ReplicationGroup.NodeGroupConfiguration NodeGroupId (added)
AWS::Events::Rule.Target SqsParameters (added)
AWS::RDS::OptionGroup.OptionConfiguration OptionSettings.DuplicatesAllowed (added)
AWS::RDS::OptionGroup.OptionConfiguration OptionSettings.ItemType (added)
AWS::RDS::OptionGroup.OptionConfiguration OptionSettings.Type (changed)
FAQs
The CDK Construct Library for AWS::Lambda
The npm package @aws-cdk/aws-lambda receives a total of 84,537 weekly downloads. As such, @aws-cdk/aws-lambda popularity was classified as popular.
We found that @aws-cdk/aws-lambda demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.